//
//  YZMUserService.h
//  YZMicroStock
//
//  Created by wangminhong on 16/3/21.
//  Copyright © 2016年 cqjr. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "YZMLoginResultModel.h"
#import "YZMUser.h"

@class YZMSUser;

extern NSString *const YZMLoginSuccessNotification;
extern NSString *const YZMLogoutSuccessNotification;
extern NSString *const YZMUserAssetsUpdateNotification;
extern NSString *const YZMUserDetailUpdateNotification;
extern NSString *const YZMUserDetailUpdateFailureNotification;
extern NSString *const YZMUserWalletUpdateNotification;
extern NSString *const YZMUserBankCardUpdateNotification;

extern NSString *const YZMBankCardAddSuccessNotification;
extern NSString *const YZMBankCardDeleteSuccessNotification;

@interface YZMUserService : NSObject


@property (nonatomic, strong, readonly) YZMLoginResultModel *currentUser;

@property (nonatomic, strong, readonly) YZMUser *user;
@property (nonatomic, readonly, getter=isValidate) BOOL validate;
@property (nonatomic, assign) BOOL authorized;
@property (nonatomic, strong) NSString *historyUsername;
@property (nonatomic, assign, readonly) BOOL networkRequstValid;


+ (instancetype)sharedService;

+ (void)showLoginCtrl;
+ (void)showLoginCtrlWithPageName:(NSString *)pageName;
+ (void)showLoginCtrlWithPageName:(NSString *)pageName andPageParams:(NSDictionary *)params;
+ (void)showLoginCtrlWithSourcePageName:(NSString *)sourcePageName andAheadAction:(void (^)())aheadAction andBackAction:(void (^)())backAction;
+ (void)showLoginCtrlWithSourcePageName:(NSString *)sourcePageName andBackAction:(void (^)())backAction;
+ (void)showLoginCtrlWithSourcePageName:(NSString *)sourcePageName;
+ (void)showRegisterCtrlWithPageName:(NSString *)pageName;

+ (void)pushByCheckingAuthWithName:(NSString *)name andParams:(NSDictionary *)params;

- (void)loginSuccess: (void (^)(YZMLoginResultModel *result))success failure: (void (^)(NSError *error))failure;
- (void)login;
- (void)logout;
- (BOOL)checkPassword:(NSString *)password;

/**
 * 登录
 */
- (void)loginWithUsername: (NSString *)username password: (NSString *)password success: (void (^)(YZMLoginResultModel *result))success failure: (void (^)(NSError *error))failure;

- (void)logoutSuccess: (void (^)())success failure: (void (^)(NSError *error))failure;

- (void)fetchUserAssetsSuccess: (void (^)())success failure: (void (^)(NSError *error))failure;
- (void)fetchUserAssetsInfo;
- (void)fetchUserDetailInfo;
- (void)fetchUserDetailSuccess:(void (^)())sucess failure: (void (^)(NSError *error))failure;
- (void)fetchUserBankCardInfo;
- (void)fetchUserBankCardSuccess:(void (^)())sucess failure: (void (^)(NSError *error))failure;
- (void)submitToAddBankCardWithBankName:(NSString *)bankName andProvinceName:(NSString *)provinceName andCityName:(NSString *)cityName andBranchName:(NSString *)branchName andCardNumber:(NSString *)cardNumber
                                success: (void (^)())sucess failure: (void (^)(NSError *error))failure;
/*启动心跳操作*/
+ (void)startBackgroundTask;

/*停止心跳操作*/
+ (void)stopBackgroundTask;

@end
